/*
 * @Author       : Hejh(3010733382@qq.com)
 * @Version      : V1.0
 * @Date         : 2024-01-30 11:01:15
 * @Description  : 章节相关接口
 */

import type {
  ChapterCreateReq,
  ChapterPageRes,
  ChapterReq,
  ChapterUpdateReq
} from '@/types/chapter'
import request from '@/utils/request'

// 分页查询章节接口
export const getChapterByPage = (params?: ChapterReq) => {
  return request.get<ChapterPageRes>('/chapter/list', { params })
}

// 添加章节接口
export const createChapter = (data: ChapterCreateReq) => {
  return request.post('/chapter/create', data)
}

// 更新章节接口
export const updateChapter = (data: ChapterUpdateReq) => {
  return request.put('/chapter/update', data)
}

// 章节排序接口
export const sortChapter = (chapterIds: string[]) => {
  return request.put('/chapter/sort', { chapterIds })
}

// 章节删除接口
export const delChapter = (chapterIds: string[], picCode?: string) => {
  return request.delete('/chapter/delete', { data: { chapterIds, picCode } })
}
